<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>放大字体</title>
    <style>
        * {
            margin: 0;
            padding: 0; 
        }
        .box {
            display: flex;
            flex-wrap: wrap;
            justify-content: center;
            background-color: #f0f0f0;
        }
        .box1 {
            display: flex;
            justify-content: center;
            align-items: center;
            width: 100%;
            padding: 10px; 
            gap: 20px;    
        }
        .litter {
            margin-top: 4rem;
            width: 150px;
            height: 100px;
            background-color: #fff;
            border: 1px solid #ccc;
            border-radius: 50%;
            display: flex;
            justify-content: center; 
            align-items: center;
        }
       .trash-can {
             margin-top: 30vh;
              width: 200px;
              height: 200px;
              background-color: #fff;
              border: 1px solid #ccc;
       }
    </style>
</head>
<body>
    <input type="button" value="放大字体"  onclick="enlargeText()">
    <input type="button" value="缩小字体" onclick="suoxiao()">
    <p id="text" style="font-size: 10px;" >这是一个可以放大字体的段落。</p>

    <div class="box">
        <div class="box1">
            <div class="litter">厨余垃圾</div>
            <div class="litter">可回收垃圾</div>
            <div class="litter">有害垃圾</div>
        </div>

        <div class="trash-can"></div>
    </div>
</body>
    <script>
        function enlargeText() {
            var textElement = document.getElementById('text');
            // 获取文本元素属性
            var size = parseInt(textElement.style.fontSize);
            //每次单机字体大小加10px
            textElement.style.fontSize = size + 10 + 'px';
        }
        function suoxiao() {
            var textElement = document.getElementById('text');
            // 获取文本元素属性
            var size = parseInt(textElement.style.fontSize);
            //每次单机字体大小加10px
            if (size > 10) {
                textElement.style.fontSize = size - 10 + 'px';
            }else {
                alert("字体太小了")
            }
        }
    </script>
</html>